package com.lxn.workQueue;

import com.lxn.ConnectionUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

//发送
public class Send {
    //队列名字
    public static final String NAME_WORKQUEUE = "workQueue";
    public static void main(String[] args) throws Exception {
        //连接工具获取连接对象
        Connection connection = ConnectionUtil.getConnection();
        //创建通道
        Channel channel = connection.createChannel();
        //使用默认交换机
        //创建队列
        channel.queueDeclare(NAME_WORKQUEUE,true,false,false,null);
        //发消息
        String msg = "work queue MQ";
        channel.basicPublish("",NAME_WORKQUEUE,null,msg.getBytes());
        System.out.println("发送成功!"+msg);

    }

}
